package com.kun.service;

import com.kun.mapper.UserMapper;
import com.kun.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Version:v1.0
 * @Author: 鲁坤
 * @Date: 2021-04-08
 * @ClassName: UserImpl
 * @Description: TODO
 */
@Service("UserService")
public class UserImpl implements UserService{
    @Autowired
    private UserMapper userMapper;
    @Override
    @CachePut(value = "allUsers",key = "#rstatus")
    public List<User> queryUserByRstatus(int rstatus) {
        return userMapper.queryUserByRstatus(rstatus);
    }

    @Override
    @Cacheable(value = "username",key="#username")
    public User queryUserByUsername(String username) {
        return userMapper.queryUserByUsername(username);
    }

    @Override
    @CachePut(value = "userId",key = "#uid")
    public User queryUserByUid(int uid) {
        return userMapper.queryUserByUid(uid);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int addUser(User user) {
        return userMapper.addUser(user);
    }

    @Override
    public int deleteUserByUid(int uid) {
        return userMapper.deleteUserByUid(uid);
    }
}
